{
  "author": "Gruk",
  "category": "Movement",
  "extensionNamespace": "",
  "fullName": "Timed Back and Forth Movement",
  "helpPath": "",
  "iconUrl": "",
  "name": "TimedBackAndForthMovement",
  "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/repeat.svg",
  "shortDescription": "This behavior moves objects back and forth for a chosen time or distance, vertically or horizontally.",
  "version": "1.0.1",
  "description": [
    "This behavior moves an object (like an enemy) for a chosen time or distance, then flips it and starts over, moving the object back and forth, vertically or horizontally.",
    "",
    "Note: animations must be facing **Right** (for horizontal) or **Down** (for vertical) direction."
  ],
  "origin": {
    "identifier": "TimedBackAndForthMovement",
    "name": "gdevelop-extension-store"
  },
  "tags": [
    "enemy",
    "movement",
    "back",
    "forth",
    "up",
    "down",
    "left",
    "right"
  ],
  "authorIds": [
    "9hfK9vapfgUot6y3ARuuRkPBWPJ2"
  ],
  "dependencies": [],
  "eventsFunctions": [],
  "eventsBasedBehaviors": [
    {
      "description": "Move an object (e.g. enemy) for a chosen time or distance, then flip it and start over. \nNote: animations should be facing LEFT.",
      "fullName": "Timed Back and Forth Movement",
      "name": "TimedBackAndForthMirroredMovement",
      "objectType": "Sprite",
      "eventsFunctions": [
        {
          "fullName": "",
          "functionType": "Action",
          "name": "doStepPreEvents",
          "sentence": "",
          "events": [
            {
              "type": "BuiltinCommonInstructions::Comment",
              "color": {
                "b": 109,
                "g": 230,
                "r": 255,
                "textB": 0,
                "textG": 0,
                "textR": 0
              },
              "comment": "vertical mode"
            },
            {
              "type": "BuiltinCommonInstructions::Standard",
              "conditions": [
                {
                  "type": {
                    "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::PropertyVertical"
                  },
                  "parameters": [
                    "Object",
                    "Behavior"
                  ]
                }
              ],
              "actions": [],
              "events": [
                {
                  "type": "BuiltinCommonInstructions::Comment",
                  "color": {
                    "b": 109,
                    "g": 230,
                    "r": 255,
                    "textB": 0,
                    "textG": 0,
                    "textR": 0
                  },
                  "comment": "initialize"
                },
                {
                  "type": "BuiltinCommonInstructions::Standard",
                  "conditions": [
                    {
                      "type": {
                        "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::PropertyStartPosition"
                      },
                      "parameters": [
                        "Object",
                        "Behavior",
                        "=",
                        "0"
                      ]
                    }
                  ],
                  "actions": [
                    {
                      "type": {
                        "value": "ResetObjectTimer"
                      },
                      "parameters": [
                        "Object",
                        "\"BacknForth_timeout\""
                      ]
                    },
                    {
                      "type": {
                        "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::SetPropertyStartPosition"
                      },
                      "parameters": [
                        "Object",
                        "Behavior",
                        "=",
                        "round(Object.Y())"
                      ]
                    }
                  ]
                },
                {
                  "colorB": 228,
                  "colorG": 176,
                  "colorR": 74,
                  "creationTime": 0,
                  "name": "Flips",
                  "source": "",
                  "type": "BuiltinCommonInstructions::Group",
                  "events": [
                    {
                      "type": "BuiltinCommonInstructions::Comment",
                      "color": {
                        "b": 109,
                        "g": 230,
                        "r": 255,
                        "textB": 0,
                        "textG": 0,
                        "textR": 0
                      },
                      "comment": "distance has been reached, flip it"
                    },
                    {
                      "type": "BuiltinCommonInstructions::Standard",
                      "conditions": [
                        {
                          "type": {
                            "value": "PosY"
                          },
                          "parameters": [
                            "Object",
                            "<",
                            "Object.Behavior::PropertyStartPosition() - Object.Behavior::PropertyDistance()"
                          ]
                        },
                        {
                          "type": {
                            "value": "FlippedY"
                          },
                          "parameters": [
                            "Object"
                          ]
                        }
                      ],
                      "actions": [
                        {
                          "type": {
                            "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::SetPropertyStartPosition"
                          },
                          "parameters": [
                            "Object",
                            "Behavior",
                            "=",
                            "round(Object.Y())"
                          ]
                        },
                        {
                          "type": {
                            "value": "ResetObjectTimer"
                          },
                          "parameters": [
                            "Object",
                            "\"BacknForth_timeout\""
                          ]
                        },
                        {
                          "type": {
                            "value": "FlipY"
                          },
                          "parameters": [
                            "Object",
                            "no"
                          ]
                        }
                      ]
                    },
                    {
                      "type": "BuiltinCommonInstructions::Standard",
                      "conditions": [
                        {
                          "type": {
                            "value": "PosY"
                          },
                          "parameters": [
                            "Object",
                            ">",
                            "Object.Behavior::PropertyStartPosition() + Object.Behavior::PropertyDistance()"
                          ]
                        },
                        {
                          "type": {
                            "inverted": true,
                            "value": "FlippedY"
                          },
                          "parameters": [
                            "Object"
                          ]
                        }
                      ],
                      "actions": [
                        {
                          "type": {
                            "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::SetPropertyStartPosition"
                          },
                          "parameters": [
                            "Object",
                            "Behavior",
                            "=",
                            "round(Object.Y())"
                          ]
                        },
                        {
                          "type": {
                            "value": "ResetObjectTimer"
                          },
                          "parameters": [
                            "Object",
                            "\"BacknForth_timeout\""
                          ]
                        },
                        {
                          "type": {
                            "value": "FlipY"
                          },
                          "parameters": [
                            "Object",
                            "yes"
                          ]
                        }
                      ]
                    }
                  ],
                  "parameters": []
                },
                {
                  "colorB": 228,
                  "colorG": 176,
                  "colorR": 74,
                  "creationTime": 0,
                  "name": "Timeout",
                  "source": "",
                  "type": "BuiltinCommonInstructions::Group",
                  "events": [
                    {
                      "type": "BuiltinCommonInstructions::Comment",
                      "color": {
                        "b": 109,
                        "g": 230,
                        "r": 255,
                        "textB": 0,
                        "textG": 0,
                        "textR": 0
                      },
                      "comment": "max time has been reached, flip it"
                    },
                    {
                      "type": "BuiltinCommonInstructions::Standard",
                      "conditions": [
                        {
                          "type": {
                            "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::PropertyTimecheck"
                          },
                          "parameters": [
                            "Object",
                            "Behavior",
                            "!=",
                            "Object.ObjectTimerElapsedTime(\"BacknForth_timeout\")"
                          ]
                        },
                        {
                          "type": {
                            "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::PropertyLastPosition"
                          },
                          "parameters": [
                            "Object",
                            "Behavior",
                            "=",
                            "round(Object.Y())"
                          ]
                        }
                      ],
                      "actions": [],
                      "events": [
                        {
                          "type": "BuiltinCommonInstructions::Standard",
                          "conditions": [
                            {
                              "type": {
                                "value": "ObjectTimer"
                              },
                              "parameters": [
                                "Object",
                                "\"BacknForth_timeout\"",
                                "Object.Behavior::PropertyTimeout()"
                              ]
                            },
                            {
                              "type": {
                                "value": "FlippedY"
                              },
                              "parameters": [
                                "Object"
                              ]
                            }
                          ],
                          "actions": [
                            {
                              "type": {
                                "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::SetPropertyStartPosition"
                              },
                              "parameters": [
                                "Object",
                                "Behavior",
                                "=",
                                "round(Object.Y())"
                              ]
                            },
                            {
                              "type": {
                                "value": "ResetObjectTimer"
                              },
                              "parameters": [
                                "Object",
                                "\"BacknForth_timeout\""
                              ]
                            },
                            {
                              "type": {
                                "value": "FlipY"
                              },
                              "parameters": [
                                "Object",
                                "no"
                              ]
                            }
                          ]
                        },
                        {
                          "type": "BuiltinCommonInstructions::Standard",
                          "conditions": [
                            {
                              "type": {
                                "value": "ObjectTimer"
                              },
                              "parameters": [
                                "Object",
                                "\"BacknForth_timeout\"",
                                "Object.Behavior::PropertyTimeout()"
                              ]
                            },
                            {
                              "type": {
                                "inverted": true,
                                "value": "FlippedY"
                              },
                              "parameters": [
                                "Object"
                              ]
                            }
                          ],
                          "actions": [
                            {
                              "type": {
                                "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::SetPropertyStartPosition"
                              },
                              "parameters": [
                                "Object",
                                "Behavior",
                                "=",
                                "round(Object.Y())"
                              ]
                            },
                            {
                              "type": {
                                "value": "ResetObjectTimer"
                              },
                              "parameters": [
                                "Object",
                                "\"BacknForth_timeout\""
                              ]
                            },
                            {
                              "type": {
                                "value": "FlipY"
                              },
                              "parameters": [
                                "Object",
                                "yes"
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ],
                  "parameters": []
                },
                {
                  "colorB": 228,
                  "colorG": 176,
                  "colorR": 74,
                  "creationTime": 0,
                  "name": "Movement",
                  "source": "",
                  "type": "BuiltinCommonInstructions::Group",
                  "events": [
                    {
                      "type": "BuiltinCommonInstructions::Standard",
                      "conditions": [
                        {
                          "type": {
                            "inverted": true,
                            "value": "FlippedY"
                          },
                          "parameters": [
                            "Object"
                          ]
                        }
                      ],
                      "actions": [
                        {
                          "type": {
                            "value": "AddForceXY"
                          },
                          "parameters": [
                            "Object",
                            "0",
                            "Object.Behavior::PropertySpeed()",
                            ""
                          ]
                        }
                      ]
                    },
                    {
                      "type": "BuiltinCommonInstructions::Standard",
                      "conditions": [
                        {
                          "type": {
                            "value": "FlippedY"
                          },
                          "parameters": [
                            "Object"
                          ]
                        }
                      ],
                      "actions": [
                        {
                          "type": {
                            "value": "AddForceXY"
                          },
                          "parameters": [
                            "Object",
                            "0",
                            "- \nObject.Behavior::PropertySpeed()",
                            ""
                          ]
                        }
                      ]
                    },
                    {
                      "type": "BuiltinCommonInstructions::Standard",
                      "conditions": [],
                      "actions": [
                        {
                          "type": {
                            "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::SetPropertyLastPosition"
                          },
                          "parameters": [
                            "Object",
                            "Behavior",
                            "=",
                            "round(Object.Y())"
                          ]
                        }
                      ]
                    }
                  ],
                  "parameters": []
                }
              ]
            },
            {
              "type": "BuiltinCommonInstructions::Comment",
              "color": {
                "b": 109,
                "g": 230,
                "r": 255,
                "textB": 0,
                "textG": 0,
                "textR": 0
              },
              "comment": "horizontal mode"
            },
            {
              "type": "BuiltinCommonInstructions::Standard",
              "conditions": [
                {
                  "type": {
                    "inverted": true,
                    "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::PropertyVertical"
                  },
                  "parameters": [
                    "Object",
                    "Behavior"
                  ]
                }
              ],
              "actions": [],
              "events": [
                {
                  "type": "BuiltinCommonInstructions::Comment",
                  "color": {
                    "b": 109,
                    "g": 230,
                    "r": 255,
                    "textB": 0,
                    "textG": 0,
                    "textR": 0
                  },
                  "comment": "initialize"
                },
                {
                  "type": "BuiltinCommonInstructions::Standard",
                  "conditions": [
                    {
                      "type": {
                        "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::PropertyStartPosition"
                      },
                      "parameters": [
                        "Object",
                        "Behavior",
                        "=",
                        "0"
                      ]
                    }
                  ],
                  "actions": [
                    {
                      "type": {
                        "value": "ResetObjectTimer"
                      },
                      "parameters": [
                        "Object",
                        "\"BacknForth_timeout\""
                      ]
                    },
                    {
                      "type": {
                        "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::SetPropertyStartPosition"
                      },
                      "parameters": [
                        "Object",
                        "Behavior",
                        "=",
                        "round(Object.X())"
                      ]
                    }
                  ]
                },
                {
                  "colorB": 228,
                  "colorG": 176,
                  "colorR": 74,
                  "creationTime": 0,
                  "folded": true,
                  "name": "Flips",
                  "source": "",
                  "type": "BuiltinCommonInstructions::Group",
                  "events": [
                    {
                      "type": "BuiltinCommonInstructions::Comment",
                      "color": {
                        "b": 109,
                        "g": 230,
                        "r": 255,
                        "textB": 0,
                        "textG": 0,
                        "textR": 0
                      },
                      "comment": "distance has been reached, flip it"
                    },
                    {
                      "type": "BuiltinCommonInstructions::Standard",
                      "conditions": [
                        {
                          "type": {
                            "value": "PosX"
                          },
                          "parameters": [
                            "Object",
                            ">",
                            "Object.Behavior::PropertyStartPosition() + Object.Behavior::PropertyDistance()"
                          ]
                        },
                        {
                          "type": {
                            "inverted": true,
                            "value": "FlippedX"
                          },
                          "parameters": [
                            "Object"
                          ]
                        }
                      ],
                      "actions": [
                        {
                          "type": {
                            "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::SetPropertyStartPosition"
                          },
                          "parameters": [
                            "Object",
                            "Behavior",
                            "=",
                            "round(Object.X())"
                          ]
                        },
                        {
                          "type": {
                            "value": "ResetObjectTimer"
                          },
                          "parameters": [
                            "Object",
                            "\"BacknForth_timeout\""
                          ]
                        },
                        {
                          "type": {
                            "value": "FlipX"
                          },
                          "parameters": [
                            "Object",
                            "yes"
                          ]
                        }
                      ]
                    },
                    {
                      "type": "BuiltinCommonInstructions::Standard",
                      "conditions": [
                        {
                          "type": {
                            "value": "PosX"
                          },
                          "parameters": [
                            "Object",
                            "<",
                            "Object.Behavior::PropertyStartPosition() - Object.Behavior::PropertyDistance()"
                          ]
                        },
                        {
                          "type": {
                            "value": "FlippedX"
                          },
                          "parameters": [
                            "Object"
                          ]
                        }
                      ],
                      "actions": [
                        {
                          "type": {
                            "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::SetPropertyStartPosition"
                          },
                          "parameters": [
                            "Object",
                            "Behavior",
                            "=",
                            "round(Object.X())"
                          ]
                        },
                        {
                          "type": {
                            "value": "ResetObjectTimer"
                          },
                          "parameters": [
                            "Object",
                            "\"BacknForth_timeout\""
                          ]
                        },
                        {
                          "type": {
                            "value": "FlipX"
                          },
                          "parameters": [
                            "Object",
                            "no"
                          ]
                        }
                      ]
                    }
                  ],
                  "parameters": []
                },
                {
                  "colorB": 228,
                  "colorG": 176,
                  "colorR": 74,
                  "creationTime": 0,
                  "folded": true,
                  "name": "Timeout",
                  "source": "",
                  "type": "BuiltinCommonInstructions::Group",
                  "events": [
                    {
                      "type": "BuiltinCommonInstructions::Comment",
                      "color": {
                        "b": 109,
                        "g": 230,
                        "r": 255,
                        "textB": 0,
                        "textG": 0,
                        "textR": 0
                      },
                      "comment": "max time has been reached, flip it"
                    },
                    {
                      "type": "BuiltinCommonInstructions::Standard",
                      "conditions": [
                        {
                          "type": {
                            "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::PropertyTimecheck"
                          },
                          "parameters": [
                            "Object",
                            "Behavior",
                            "!=",
                            "Object.ObjectTimerElapsedTime(\"BacknForth_timeout\")"
                          ]
                        },
                        {
                          "type": {
                            "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::PropertyLastPosition"
                          },
                          "parameters": [
                            "Object",
                            "Behavior",
                            "=",
                            "round(Object.X())"
                          ]
                        }
                      ],
                      "actions": [],
                      "events": [
                        {
                          "type": "BuiltinCommonInstructions::Standard",
                          "conditions": [
                            {
                              "type": {
                                "value": "ObjectTimer"
                              },
                              "parameters": [
                                "Object",
                                "\"BacknForth_timeout\"",
                                "Object.Behavior::PropertyTimeout()"
                              ]
                            },
                            {
                              "type": {
                                "value": "FlippedX"
                              },
                              "parameters": [
                                "Object"
                              ]
                            }
                          ],
                          "actions": [
                            {
                              "type": {
                                "value": "FlipX"
                              },
                              "parameters": [
                                "Object",
                                "no"
                              ]
                            },
                            {
                              "type": {
                                "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::SetPropertyStartPosition"
                              },
                              "parameters": [
                                "Object",
                                "Behavior",
                                "=",
                                "round(Object.X())"
                              ]
                            },
                            {
                              "type": {
                                "value": "ResetObjectTimer"
                              },
                              "parameters": [
                                "Object",
                                "\"BacknForth_timeout\""
                              ]
                            }
                          ]
                        },
                        {
                          "type": "BuiltinCommonInstructions::Standard",
                          "conditions": [
                            {
                              "type": {
                                "value": "ObjectTimer"
                              },
                              "parameters": [
                                "Object",
                                "\"BacknForth_timeout\"",
                                "Object.Behavior::PropertyTimeout()"
                              ]
                            },
                            {
                              "type": {
                                "inverted": true,
                                "value": "FlippedX"
                              },
                              "parameters": [
                                "Object"
                              ]
                            }
                          ],
                          "actions": [
                            {
                              "type": {
                                "value": "FlipX"
                              },
                              "parameters": [
                                "Object",
                                "yes"
                              ]
                            },
                            {
                              "type": {
                                "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::SetPropertyStartPosition"
                              },
                              "parameters": [
                                "Object",
                                "Behavior",
                                "=",
                                "round(Object.X())"
                              ]
                            },
                            {
                              "type": {
                                "value": "ResetObjectTimer"
                              },
                              "parameters": [
                                "Object",
                                "\"BacknForth_timeout\""
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ],
                  "parameters": []
                },
                {
                  "colorB": 228,
                  "colorG": 176,
                  "colorR": 74,
                  "creationTime": 0,
                  "folded": true,
                  "name": "Movement",
                  "source": "",
                  "type": "BuiltinCommonInstructions::Group",
                  "events": [
                    {
                      "type": "BuiltinCommonInstructions::Standard",
                      "conditions": [
                        {
                          "type": {
                            "inverted": true,
                            "value": "FlippedX"
                          },
                          "parameters": [
                            "Object"
                          ]
                        }
                      ],
                      "actions": [
                        {
                          "type": {
                            "value": "AddForceXY"
                          },
                          "parameters": [
                            "Object",
                            "Object.Behavior::PropertySpeed()",
                            "0",
                            ""
                          ]
                        }
                      ]
                    },
                    {
                      "type": "BuiltinCommonInstructions::Standard",
                      "conditions": [
                        {
                          "type": {
                            "value": "FlippedX"
                          },
                          "parameters": [
                            "Object"
                          ]
                        }
                      ],
                      "actions": [
                        {
                          "type": {
                            "value": "AddForceXY"
                          },
                          "parameters": [
                            "Object",
                            "- \nObject.Behavior::PropertySpeed()",
                            "0",
                            ""
                          ]
                        }
                      ]
                    },
                    {
                      "type": "BuiltinCommonInstructions::Standard",
                      "conditions": [],
                      "actions": [
                        {
                          "type": {
                            "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::SetPropertyLastPosition"
                          },
                          "parameters": [
                            "Object",
                            "Behavior",
                            "=",
                            "round(Object.X())"
                          ]
                        }
                      ]
                    }
                  ],
                  "parameters": []
                }
              ]
            },
            {
              "colorB": 228,
              "colorG": 176,
              "colorR": 74,
              "creationTime": 0,
              "name": "TimeCheck",
              "source": "",
              "type": "BuiltinCommonInstructions::Group",
              "events": [
                {
                  "type": "BuiltinCommonInstructions::Comment",
                  "color": {
                    "b": 109,
                    "g": 230,
                    "r": 255,
                    "textB": 0,
                    "textG": 0,
                    "textR": 0
                  },
                  "comment": "store current elapsed time (to make sure time has passed)"
                },
                {
                  "type": "BuiltinCommonInstructions::Standard",
                  "conditions": [],
                  "actions": [
                    {
                      "type": {
                        "value": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement::SetPropertyTimecheck"
                      },
                      "parameters": [
                        "Object",
                        "Behavior",
                        "=",
                        "Object.ObjectTimerElapsedTime(\"BacknForth_timeout\")"
                      ]
                    }
                  ]
                }
              ],
              "parameters": []
            }
          ],
          "parameters": [
            {
              "description": "Object",
              "name": "Object",
              "supplementaryInformation": "Sprite",
              "type": "object"
            },
            {
              "description": "Behavior",
              "name": "Behavior",
              "supplementaryInformation": "TimedBackAndForthMovement::TimedBackAndForthMirroredMovement",
              "type": "behavior"
            }
          ],
          "objectGroups": []
        }
      ],
      "propertyDescriptors": [
        {
          "value": "false",
          "type": "Boolean",
          "label": "Move the object vertically (instead of horizontally)",
          "description": "",
          "group": "",
          "extraInformation": [],
          "hidden": false,
          "name": "Vertical"
        },
        {
          "value": "100",
          "type": "Number",
          "label": "Moving speed (in pixel/s)",
          "description": "",
          "group": "",
          "extraInformation": [],
          "hidden": false,
          "name": "Speed"
        },
        {
          "value": "200",
          "type": "Number",
          "label": "Moving distance (in pixels)",
          "description": "",
          "group": "",
          "extraInformation": [],
          "hidden": false,
          "name": "Distance"
        },
        {
          "value": "2",
          "type": "Number",
          "label": "Moving maximum time (in seconds)",
          "description": "",
          "group": "",
          "extraInformation": [],
          "hidden": false,
          "name": "Timeout"
        },
        {
          "value": "0",
          "type": "Number",
          "label": "Distance start point",
          "description": "",
          "group": "",
          "extraInformation": [],
          "hidden": true,
          "name": "StartPosition"
        },
        {
          "value": "0",
          "type": "Number",
          "label": "position of the sprite at the previous frame",
          "description": "",
          "group": "",
          "extraInformation": [],
          "hidden": true,
          "name": "LastPosition"
        },
        {
          "value": "0",
          "type": "Number",
          "label": "check that time has elapsed",
          "description": "",
          "group": "",
          "extraInformation": [],
          "hidden": true,
          "name": "Timecheck"
        }
      ],
      "sharedPropertyDescriptors": []
    }
  ],
  "eventsBasedObjects": []
}